import type { MenuTab } from '@/models/menu-tab';
import { getWindowHeight } from '@/utils';
import { defineStore } from 'pinia';
export const mainStore = defineStore('main', () => {
    const collapsed: boolean = false;

    const containerHeight: number = getWindowHeight();

    const avatarHeight: number = 165;

    const headHeight: number = 55;

    const footHeight: number = 75;

    const menuTabs: Array<MenuTab> = [];

    const currentTab: MenuTab = {
        title: "",
        key: "first",
        closable: false,
        component: null,
        baseMenuButton: []
    };

    const selectedKeys: Array<string> = [];

    return {
        collapsed,
        containerHeight,
        avatarHeight,
        headHeight,
        footHeight,
        menuTabs,
        currentTab,
        selectedKeys
    }
});

export function setCurrentTab(value: MenuTab): void {
    mainStore().currentTab.title = value.title;
    mainStore().currentTab.key = value.key;
    mainStore().currentTab.closable = value.closable;
    mainStore().currentTab.component = value.component;
    mainStore().currentTab.baseMenuButton = value.baseMenuButton
}

export function setMenuTabs(values: Array<MenuTab>): void {
    mainStore().menuTabs = values;
}

export function setContainerHeight(): void {
    mainStore().containerHeight = getWindowHeight()
}

export function setAvatarHeight(value: number): void {
    mainStore().avatarHeight = value;
}

export function setCollapsed(): void {
    mainStore().selectedKeys = [];
    mainStore().collapsed = !mainStore().collapsed;
}